Xbasic

SQL::DeleteStatementExecute Method

Syntax

Result_Flag as L = Execute([SQLConnection as SQL::Connection | SQLConnectionString as C] [, Arguments as SQL::Arguments | Arguments as C])

Arguments

Result_Flag

TRUE (.T.) if the operation was successful; otherwise FALSE (.F.).

SQL::DeleteStatement

A SQL::DeleteStatement object.

SQLConnection

Optional. A SQL::Connection object and with a defined .ConnectionString property.

Arguments

Optional. A connection string.

Description

Execute the current statement using the current or passed connection. Optionally providing argument values as an object or as XML.

The .Execute() method retrieves data and populates a SQL::ResultSet object. It connects to the back-end database using the information in the SQL::Connection::ConnectionString property or in the ConnectString string, then executes the SQL statement in the SQL::DeleteStatement.SQLStatement property.

Argument values are merged with those already set on the query.

Example

Dimension the variables. This script will need SQL::Connection and SQL::DeleteStatement objects to delete the data.

dim conn as SQL::Connection
dim del as SQL::DeleteStatement
dim connString as C
dim sql_delete as C

Assign values to the character variables.

connString = "{A5API='Access', FileName='c:\program files\a5v7\mdbfiles\alphasports.mdb'}"

Note that the DELETE command uses the SubString()portability function as part of the WHERE clause.

sql_delete = "DELETE FROM Customer_copy WHERE substring(lastname,1,1) = 'A'"

Establish the connection.

IF .not. conn.open(connString) THEN
    end
END IF

Check the SQL DELETE statement.

IF .not. del.parse(sql_delete) THEN
    ui_msg_box("Error", del.callresult.text)
    end
END IF

Execute the SQL DELETE statement.

IF .not. del.execute(conn)
    ui_msg_box("Error", del.callresult.text)
    end
END IF

See Also